package com.longxiao.service;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.longxiao.entity.StudentLecture;
import com.longxiao.mapper.StudentLectureMapper;
import com.longxiao.vo.StuUserVo;

@Service("studentLectureService")
public class StudentLectureService {

	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	
	@Resource
	private StudentLectureMapper studentLectureMapper;
	
	public List<StuUserVo> getStuUserVoList(StuUserVo userVo,int offset,int rows) {
		return studentLectureMapper.selectStuUserVo(userVo, offset, rows);
	}
	
	public int countStuUserVoList(StuUserVo userVo) {
		return studentLectureMapper.countStuUserVo(userVo);
	}
	/*
	 * 充值课时
	 */
	public boolean rechargeLecture(String stuId,int rechargeLecture) {
		StudentLecture lecture = studentLectureMapper.selectByUserId(stuId);
		lecture.setBalanceLectures(lecture.getBalanceLectures() + rechargeLecture);
		return studentLectureMapper.updateByPrimaryKeySelective(lecture) > 0;
	}
}
